# Maintainer: Tim Meusel <tim@bastelfreak.de>

_gemname='ed25519'
pkgname="ruby-${_gemname}"
pkgver=1.3.0
pkgrel=1
pkgdesc='A Ruby binding to the Ed25519 elliptic curve public-key signature system described in RFC 8032.'
arch=('loong64' 'x86_64')
url="https://github.com/RubyCrypto/${_gemname}"
license=('MIT')
depends=('ruby')
makedepends=('ruby-rake' 'ruby-bundler' 'ruby-rdoc' 'ruby-rake-compiler')
checkdepends=('ruby-rspec')
options=('!emptydirs')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha512sums=('dbd108769e131d15e4f31eaf7f4a46530769f279ccbbe4a10b5fe9e1d394bafb0ea6af95b6b1da2d66db00072576ff9d6d5c9156d949d79daf929a9dbd22eea8')
provides=('ed25519_ref10.so')
prepare() {
  cd "${srcdir}/${_gemname}-${pkgver}"

  sed -E 's|~>|>=|g' --in-place "${_gemname}.gemspec"
  sed --in-place 's|`git ls-files -z`|`find . -print0`|' "${_gemname}.gemspec"
  sed --in-place '/rubocop/Id' Rakefile
  rm Gemfile
  sed --in-place '/coveralls/Id' spec/spec_helper.rb
}

build() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  rake compile
  gem build "${_gemname}.gemspec"
}

check() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  rake spec
}

package() {
  cd "${srcdir}/${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install --install-dir "${pkgdir}${_gemdir}" --bindir "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
  install -Dm 644 README.md CHANGES.md ed25519.png CODE_OF_CONDUCT.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm -rf ${pkgdir}/${_gemdir}/gems/${_gemname}-${pkgver}/{ext,tmp}
  rm -rf "${pkgdir}/${_gemdir}/cache"
  rm -rf ${pkgdir}/${_gemdir}/extensions/*/*/${_gemname}-${pkgver}/{mkmf.log,gem_make.out}
  rm -rf "${pkgdir}/${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext"
}

# vim: ts=2 sw=2 et:
